<!DOCTYPE html>

<html>
<head>
  <title>Map</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="List.coffee.html">
                List.coffee.md
              </a>
            
              
              <a class="source" href="Map.coffee.html">
                Map.coffee.md
              </a>
            
              
              <a class="source" href="Record.coffee.html">
                Record.coffee.md
              </a>
            
              
              <a class="source" href="Set.coffee.html">
                Set.coffee.md
              </a>
            
              
              <a class="source" href="Stream.coffee.html">
                Stream.coffee.md
              </a>
            
              
              <a class="source" href="Tuple.coffee.html">
                Tuple.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h1 id="map">Map</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Map = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Map</span></span>
		
		<span class="hljs-attribute">constructor</span>: <span class="hljs-function"><span class="hljs-params">( mappings )</span> -&gt;</span>
			<span class="hljs-property">@_</span> = {}
			<span class="hljs-property">@add</span> mappings <span class="hljs-keyword">if</span> mappings <span class="hljs-keyword">instanceof</span> Object

		<span class="hljs-attribute">add</span>: Function.overload [	
			Function.From<span class="hljs-function"><span class="hljs-params">(Scalar,Value)</span> <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(key,value)</span> -&gt;</span> <span class="hljs-property">@_</span>[key] = value
			Function.From<span class="hljs-function"><span class="hljs-params">(Object)</span>       <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(mappings)</span> -&gt;</span> <span class="hljs-property">@add</span>(key,value) <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> mappings
		]
		
		<span class="hljs-attribute">remove</span>: Function.Chaining <span class="hljs-function"><span class="hljs-params">(key)</span> -&gt;</span> <span class="hljs-keyword">delete</span> <span class="hljs-property">@_</span>[key]

		<span class="hljs-attribute">get</span>: <span class="hljs-function"><span class="hljs-params">(key)</span> -&gt;</span> <span class="hljs-property">@_</span>[key]
		
		<span class="hljs-attribute">keys</span>:<span class="hljs-function"> -&gt;</span> <span class="hljs-keyword">new</span> Set ( key <span class="hljs-keyword">for</span> own key <span class="hljs-keyword">of</span> <span class="hljs-property">@_</span> )

		<span class="hljs-attribute">each</span>: <span class="hljs-function"><span class="hljs-params">(fn)</span> -&gt;</span> fn(key,value) <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> <span class="hljs-property">@_</span>

		<span class="hljs-attribute">ensure</span>: Function.identity</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <h2 id="typed-maps">Typed maps</h2>

            </div>
            
            <div class="content"><div class='highlight'><pre>		
		<span class="hljs-property">@To</span>: Function.Cache.From<span class="hljs-function"><span class="hljs-params">(Function)</span>.<span class="hljs-title">To</span><span class="hljs-params">(Function)</span> <span class="hljs-params">(constructor)</span> -&gt;</span>
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">this</span></span>
			
				<span class="hljs-attribute">add</span>: <span class="hljs-attribute">this</span>::add.extend [			
					Function.From<span class="hljs-function"><span class="hljs-params">(Scalar,Value)</span> <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(key,value)</span> -&gt;</span> <span class="hljs-property">@_</span>[key] = <span class="hljs-property">@ensure</span> value
					Function.From<span class="hljs-function"><span class="hljs-params">(Array)</span>        <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(keys)</span> -&gt;</span> <span class="hljs-property">@add</span> key, <span class="hljs-property">@ensure</span>() <span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> keys
				]
				
				<span class="hljs-attribute">ensure</span>: Object.ensure constructor
				
				<span class="hljs-property">@value_constructor</span>: constructor
		
		<span class="hljs-property">@Using</span>: Function.Cache.From<span class="hljs-function"><span class="hljs-params">(Function)</span>.<span class="hljs-title">To</span><span class="hljs-params">(Function)</span> <span class="hljs-params">(combine)</span> -&gt;</span>
			combine = combine.bind <span class="hljs-property">@value_constructor</span>
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">this</span></span>
				<span class="hljs-attribute">add</span>: <span class="hljs-attribute">this</span>::add.extend [
					Function.From<span class="hljs-function"><span class="hljs-params">(Scalar,Value)</span> <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(key,value)</span> -&gt;</span>
						<span class="hljs-property">@_</span>[key] = <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> <span class="hljs-property">@_</span>[key] <span class="hljs-keyword">then</span> <span class="hljs-property">@ensure</span>(value) <span class="hljs-keyword">else</span> combine <span class="hljs-property">@ensure</span>(value), <span class="hljs-property">@_</span>[key]
				]</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
